import { RouteConfigs } from '../test.d.ts'
import { Navigate } from 'react-router-dom'

// 布局容器
import Layout from '../pages/Layout'
// 登录组件
import Login from '../pages/Login'
import Dashboard from '../pages/Dashboard'
import Employees from '../pages/Employees'
import EmployeesDetail from '../pages/Employees/detail'
import Permission from '../pages/Permission'
import Departments from '../pages/Departments'
import Setting from '../pages/Setting'
import Salarys from '../pages/Salarys'
import Approvals from '../pages/Approvals'
import Attendances from '../pages/Attendances'
import Social from '../pages/Social'
// // 导入 404 页面
import PageError from '../pages/404'

const routes: RouteConfigs[] = [
  {
    path: '/',
    element: <Layout />,
    name: '布局容器',
    children: [
      {
        index: true,
        element: <Navigate to="/dashboard" />,
        hidden: true
      },
      {
        path: 'dashboard',
        element: <Dashboard />,
        name: '首页',
        icon: 'icon-dashboard'
      },
      {
        path: 'settings',
        name: '公司设置',
        icon: 'icon-shezhi',
        element: <Setting />
      },
      {
        path: 'permissions',
        name: '权限管理',
        icon: 'icon-quanxian',
        element: <Permission />
      },
      {
        path: 'employees',
        element: <Employees />,
        name: '员工管理',
        icon: 'icon-yuangong',
        children: [{ path: 'employees/:id', element: <EmployeesDetail />, hidden: true }]
      },
      {
        path: 'departments',
        name: '组织架构',
        icon: 'icon-jurassic_organization',
        element: <Departments />,
        hidden: false
      },
      {
        path: 'salarys',
        name: '工资',
        icon: 'icon-wodegongzi',
        element: <Salarys />
      },
      {
        path: 'approvals',
        name: '审批',
        icon: 'icon-shenpi',
        element: <Approvals />
      },
      {
        path: 'attendances',
        name: '考勤',
        icon: 'icon-kaoqin',
        element: <Attendances />
      },
      {
        path: 'socials',
        name: '社保',
        icon: 'icon-shebao',
        element: <Social />
      }
    ]
  },
  {
    path: '/login',
    name: '登录',
    element: <Login />
  },
  {
    path: '*',
    name: '404',
    element: <PageError />
  }
]

// const routeArr = (routes) => {
//   // 需要进行鉴权的路由
//   let authRoute = []

//   routes.forEach((item) => {
//     if (item.children) {
//       var children = routeArr(item.children)

//       if (children.length) {
//         authRoute = authRoute.concat(children)
//       }
//     }

//     if (item.path) {
//       authRoute.push('/' + item.path)
//     }
//   })

//   return authRoute
// }

export { routes }
